package cn.topcodes.tcsf.admin.commons.api.controller.generic;

import cn.topcodes.tcsf.admin.commons.api.controller.query.QueryIdEntityApi;
import cn.topcodes.tcsf.admin.commons.api.domain.ApiResponseEntity;
import cn.topcodes.tcsf.admin.commons.domain.Idable;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * 通用操作API接口
 * @author unicorn
 * @param <F>	表单泛型
 * @param <V>	值对象泛型
 */
public interface GenericApi<F extends Idable,V> extends QueryIdEntityApi<V> {

	/*删除资源*/
	@ApiOperation(value = "删除资源", notes = "删除资源")
	@ResponseBody
	@RequestMapping(value="delete",method=RequestMethod.POST)
	ApiResponseEntity<Void> delete(@ApiParam(value="资源ID") @RequestParam(required=true) Long id);

	/*慎重删除资源*/
	@ApiOperation(value = "慎重删除资源", notes = "慎重删除资源")
	@ResponseBody
	@RequestMapping(value = "careful-delete",method = RequestMethod.POST)
	ApiResponseEntity carefulDelete(
			@ApiParam(value="资源ID") @RequestParam Long id,
			@ApiParam(value="验证密码") @RequestParam String password
	);

	/*批量删除资源*/
	@ApiOperation(value = "批量删除资源", notes = "批量删除资源")
	@ResponseBody
	@RequestMapping(value="batch-delete",method=RequestMethod.POST)
	ApiResponseEntity<Void> batchDelete(@ApiParam(value="资源ID数组") @RequestParam(required=true) Long[] ids);
	
	/*标记删除资源*/
	@ApiOperation(value = "标记删除资源", notes = "标记删除资源")
	@ResponseBody
	@RequestMapping(value="mark-delete",method=RequestMethod.POST)
	ApiResponseEntity<Void> markDelete(@ApiParam(value="资源ID") @RequestParam(required=true) Long id);
	
	/*批量标记删除资源*/
	@ApiOperation(value = "批量标记删除资源", notes = "批量标记删除资源")
	@ResponseBody
	@RequestMapping(value="batch-mark-delete",method=RequestMethod.POST)
	ApiResponseEntity<Void> batchMarkDelete(@ApiParam(value="资源ID数组") @RequestParam(required=true) Long[] ids);

	/*禁用实体*/
	@ApiOperation(value = "禁用资源", notes = "禁用资源")
	@ResponseBody
	@RequestMapping(value="disable",method=RequestMethod.POST)
	ApiResponseEntity<Void> disable(@ApiParam(value="资源ID") @RequestParam(required=true) Long id);
	
	/*批量禁用资源*/
	@ApiOperation(value = "批量禁用资源", notes = "批量禁用资源")
	@ResponseBody
	@RequestMapping(value="batch-diable",method=RequestMethod.POST)
	ApiResponseEntity<Void> batchDisable(@ApiParam(value="资源ID数组") @RequestParam(required=true) Long[] ids);
	
	/*启用实体*/
	@ApiOperation(value = "启用资源", notes = "启用资源")
	@ResponseBody
	@RequestMapping(value="enable",method=RequestMethod.POST)
	ApiResponseEntity<Void> enable(@ApiParam(value="资源ID") @RequestParam(required=true) Long id);
	
	/*批量启用实体*/
	@ApiOperation(value = "批量启用资源", notes = "批量启用资源")
	@ResponseBody
	@RequestMapping(value="batch-enable",method=RequestMethod.POST)
	ApiResponseEntity<Void> batchEnable(@ApiParam(value="资源ID数组") @RequestParam(required=true) Long[] ids);
	
	/*创建资源*/
	@ApiOperation(value = "创建资源", notes = "创建资源")
	@ResponseBody
	@RequestMapping(value="create",method=RequestMethod.POST)
	ApiResponseEntity<Void> create(
			HttpServletRequest request,
			@Valid @ApiParam(value="创建资源表单") @RequestParam(required=true) F form,
			BindingResult result);
	
	/*批量创建资源*/
	@ApiOperation(value = "批量创建资源", notes = "批量创建资源")
	@ResponseBody
	@RequestMapping(value="batch-create",method=RequestMethod.POST)
	ApiResponseEntity<Void> batchCreate(
			HttpServletRequest request,
	        @Valid @ApiParam(value="批量创建资源表单数组") @RequestParam(required=true) F[] forms,
			BindingResult result);
	
	/*更新资源*/
	@ApiOperation(value = "更新资源", notes = "更新资源")
	@ResponseBody
	@RequestMapping(value="update",method=RequestMethod.POST)
	ApiResponseEntity<Void> update(
			HttpServletRequest request,
			@Valid @ApiParam(value="更新资源表单") @RequestParam(required=true) F form,
			BindingResult result);
	
	/*批量更新资源*/
	@ApiOperation(value = "批量更新资源", notes = "批量更新资源")
	@ResponseBody
	@RequestMapping(value="batch-update",method=RequestMethod.POST)
	ApiResponseEntity<Void> batchUpdate(
			HttpServletRequest request,
			@Valid @ApiParam(value="批量更新资源表单数组") @RequestParam(required=true) F[] forms,
			BindingResult result);
}
